package cn.hsa.xxx.bookOrder.dto;

import cn.hsa.xxx.bookOrder.entity.OrderDetailsDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;


@Component
public class OrderDetailsDTOConverter {

    /**
     * Convert OrderDetailsDTO to OrderDetailsDO
     *
     * @param orderDetailsDTO
     * @return
     */
    public OrderDetailsDO convertToOrderDetailsDO(OrderDetailsDTO orderDetailsDTO) {
        if (orderDetailsDTO == null) {
            return null;
        }
        OrderDetailsDO orderDetailsDO = new OrderDetailsDO();

        //OrderDetailsDO.setId(OrderDetailsDTO.getId());
        //OrderDetailsDO.setName(OrderDetailsDTO.getName());
        //OrderDetailsDO.setSex(OrderDetailsDTO.getSex());
        //OrderDetailsDO.setAddr(OrderDetailsDTO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(orderDetailsDTO, orderDetailsDO);

        return orderDetailsDO;
    }

    /**
     * Convert OrderDetailsDO to OrderDetailsDTO
     *
     * @param orderDetailsDO
     * @return
     */
    public OrderDetailsDTO convertToOrderDetailsDTO(OrderDetailsDO orderDetailsDO) {
        if (orderDetailsDO == null) {
            return null;
        }

        OrderDetailsDTO orderDetailsDTO = new OrderDetailsDTO();

        //OrderDetailsDTO.setId(OrderDetailsDO.getId());
        //OrderDetailsDTO.setName(OrderDetailsDO.getName());
        //OrderDetailsDTO.setSex(OrderDetailsDO.getSex());
        //OrderDetailsDTO.setAddr(OrderDetailsDO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(orderDetailsDO, orderDetailsDTO);

        return orderDetailsDTO;
    }
}
